package com.zc.im.common.vo;

import com.zc.im.common.constant.enums.ResultEnum;

/**
 * Project：im
 * Date：2022/4/13
 * Time：19:02
 * Description：Result
 *
 * @author Challen.Zhang
 * @version 1.0
 */
public class Result<T> {

    private Integer status;

    private String message;

    private T data;

    public Result(ResultEnum resultEnum) {
        this.status = resultEnum.getStatus();
        this.message = resultEnum.getMessage();
    }

    public Result(ResultEnum resultEnum, T t) {
        this.status = resultEnum.getStatus();
        this.message = resultEnum.getMessage();
        this.data = t;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public boolean isSuccess() {
        return status == ResultEnum.OK.getStatus();
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(ResultEnum.OK, data);
    }

}
